package com.yundasys.lab06ratelimitannotation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.support.ResourceScriptSource;

/**
 * @author jiangta
 * @version 1.0
 * @date 2021/6/10 6:00 下午
 */
@Configuration
public class LuaConfiguration {

    @Bean
    public DefaultRedisScript<Boolean> redisScript() {
        DefaultRedisScript<Boolean> redisScript = new DefaultRedisScript<>();
        redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("luascript/lua1.lua")));
        redisScript.setResultType(Boolean.class);
        return redisScript;
    }
}
